//////////////////////////////////////////////////////////////////////////
//
// GAM203
// Quad class
// Quad.h
// 
// Grant Johnson
// Qantm College
// 27/10/2010
//
//////////////////////////////////////////////////////////////////////////

#ifndef PARTICLEQUAD_H
#define PARTICLEQUAD_H

#include <d3dx9.h>
#include "RenderParams.h"

class ParticleQuad
{
public:
	// Vertex format we will use to describe our vertices (must match FVF format below)
	struct VertexData
	{
		D3DVECTOR pos;
		D3DVECTOR norm;
		D3DCOLOR col;
		FLOAT u,v;
	};

	// DirectX's way of identifying what's in our vertex structure (we bitwise OR these values)
	static const DWORD VERTEX_FORMAT = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1;

	ParticleQuad();
	~ParticleQuad();

	//////////////////////////////////////////////////////////////////////////
	// Inherited from Drawable
	// For creating the drawable object
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	// a_pTexFileName, a path passed into the function. This can either be used for
	// the texture file name, or for a mesh's file name.
	//
	// Returns false if any step of the creation failed
	// Returns true if created successfully
	//
	//////////////////////////////////////////////////////////////////////////
	bool CreateObject(IDirect3DDevice9* a_pDevice, char* a_pTexFileName);

	//////////////////////////////////////////////////////////////////////////
	// Inherited from Drawable
	// For rendering the drawable object
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	void Render(float a_dt, IDirect3DDevice9* a_pDevice, const RenderParams& a_renderParams);

	//////////////////////////////////////////////////////////////////////////
	// Set a world matrix to that of the Drawable object
	//
	// Paramaters:
	// a_newWorldMat, a const reference to a matrix with the transformations
	// to be applied to the object
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	void SetWorldMatrix(const D3DXMATRIX& a_newWorldMat);
	
	//////////////////////////////////////////////////////////////////////////
	// Get the world matrix of the drawable object
	//
	// Paramaters:
	// None
	//
	// Returns a const reference to the member data world matrix
	//
	//////////////////////////////////////////////////////////////////////////
	const D3DXMATRIX& GetWorldMatrix() const;

	void SetAlpha(float a_val) { m_alpha = a_val; }
	void SetRotation(float a_val) { m_rot = a_val; }
	void SetColour(D3DXCOLOR a_colour) { m_colour = a_colour; }

	const IDirect3DVertexBuffer9* GetVertexBuffer() const { return m_pVertexBuffer; }
	const IDirect3DIndexBuffer9* GetIndexBuffer() const { return m_pIndexBuffer; }

private:
	//Store vertex and index data
	IDirect3DVertexBuffer9* m_pVertexBuffer;
	IDirect3DIndexBuffer9* m_pIndexBuffer;

	//World Matrix
	D3DXMATRIX m_worldMatrix;

	//Filename of the texture to apply to the drawable object
	char* m_pTexFilename;
	
	//Direct3D texture pointer
	IDirect3DTexture9* m_pTex;

	float m_alpha;
	D3DXCOLOR m_colour;
	float m_rot;
};

#endif //PARTICLEQUAD_H

